sgwt_randmat : Compute random (Erdos-Renyi model) graph function A=sgwt_randmat(N,thresh) Inputs : N - number of vertices thresh - probability of connection of each edge Outputs : A - adjacency matrix
0001 % sgwt_randmat : Compute random (Erdos-Renyi model) graph 0002 % 0003 % function A=sgwt_randmat(N,thresh) 0004 % 0005 % Inputs : 0006 % N - number of vertices 0007 % thresh - probability of connection of each edge 0008 % 0009 % Outputs : 0010 % A - adjacency matrix 0011 0012 % This file is part of the SGWT toolbox (Spectral Graph Wavelet Transform toolbox) 0013 % Copyright (C) 2010, David K. Hammond. 0014 % 0015 % The SGWT toolbox is free software: you can redistribute it and/or modify 0016 % it under the terms of the GNU General Public License as published by 0017 % the Free Software Foundation, either version 3 of the License, or 0018 % (at your option) any later version. 0019 % 0020 % The SGWT toolbox is distributed in the hope that it will be useful, 0021 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0022 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0023 % GNU General Public License for more details. 0024 % 0025 % You should have received a copy of the GNU General Public License 0026 % along with the SGWT toolbox. If not, see <http://www.gnu.org/licenses/>. 0027 0028 function [A]=sgwt_randmat(N,thresh) 0029 assert(thresh<=1 && thresh>=0); 0030 A=rand(N)>1-thresh; 0031 B=triu(A); 0032 A=B+B'; 0033 for i=1:size(A,1) 0034 A(i,i)=0; 0035 end 0036 A=sparse(A);